
# 编译测试程序
find_package(GTest CONFIG)
find_package(yaml-cpp REQUIRED)

function(add_google_test test_target)
    add_executable(${test_target} ${test_target}.cpp)
    target_include_directories(${test_target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ ${GOOGLETEST_LIBS_DIR})
    target_link_libraries(${test_target} GTest::gtest GTest::gtest_main yaml-cpp::yaml-cpp downlink)
    target_include_directories(${test_target} PUBLIC ${GOOGLETEST_INCLUDE_DIR})
    add_test(NAME ${test_target} COMMAND ${test_target})
endfunction()

add_google_test(downlink_test)
set_tests_properties(downlink_test PROPERTIES
    ENVIRONMENT "TEST_CHANNEL=/dev/ttyS1"
)
install(FILES downlink_test.yaml
        DESTINATION $<CONFIG>/testfiles/
        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ)
